import React from 'react'
import { Route, IndexRoute } from 'react-router'

import {
    App,
    Home,  //主页
    AuthError, //授权失败页
    NotFoundPage,
	Paysuccess, //支付成功页
	Payment, //订单确认页
	HandlingProgress, //进度详情
	AddAddress, //添加地址
	AddressEdit, //编辑地址
	AddressList,  //地址列表
	OrderList, //我的订单
	OrderDetails, //订单详情页
	AddPass, //添加通行证
	PassInformation, //通行证信息页，订单详情页进入
    Agreement,

    CheckExpress,
    CheckProgress
} from './containers'

export default (
  <Route path="/" component={App}>
    <IndexRoute component={Home}/>
    <Route path="authError" components={AuthError}/>

    {/* <Route path="authError" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/authError').default)
        }, 'authError')
    }} />
    <Route path="paysuccess" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/paysuccess').default)
        }, 'paysuccess')
    }} />
    <Route path="payment" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/payment').default)
        }, 'payment')
    }} />
    <Route path="handlingProgress/:orderId/:chargeId" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/handlingProgress').default)
        }, 'handlingProgress')
    }} />
    <Route path="addAddress" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/addAddress').default)
        }, 'addAddress')
    }} />
    <Route path="addressEdit/:addressId" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/addressEdit').default)
        }, 'addressEdit')
    }} />
    <Route path="addressList" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/addressList').default)
        }, 'addressList')
    }} />
    <Route path="orderList(/:type)" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/orderList').default)
        }, 'orderList')
    }} />
    <Route path="orderDetails/:orderId/:chargeId(/:type)" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/orderDetails').default)
        }, 'orderDetails')
    }} />
    <Route path="addPass(/:id)(/:type)" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/addPass').default)
        }, 'addPass')
    }} />
    <Route path="passInformation(/:type)" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/passInformation').default)
        }, 'passInformation')
    }} />


    <Route path="twHome" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/twHome').default)
        }, 'twHome')
    }} />
    <Route path="twPayment" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/twPayment').default)
        }, 'twPayment')
    }} />

    <Route path="twAddPass(/:id)(/:type)" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/twAddPass').default)
        }, 'twAddPass')
    }} />
    <Route path="twPassInformation(/:type)" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/twPassInformation').default)
        }, 'twPassInformation')
    }} />
    <Route path="twPaysuccess" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/twPaysuccess').default)
        }, 'twPaysuccess')
    }} />
    <Route path="twOrderDetails/:orderId/:chargeId(/:type)" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/twOrderDetails').default)
        }, 'twOrderDetails')
    }} />
    <Route path="twHandlingProgress/:orderId/:chargeId" getComponent={(nextState, cb) => {
        require.ensure([], (require) => {
            cb(null, require('./containers/twOrderDetails').default)
        }, 'twOrderDetails')
    }} /> */}
    

    <Route path="paysuccess" components={Paysuccess}/>
    <Route path="payment(/:orderId)(/:chargeOrderId)" components={Payment}/>
    <Route path="handlingProgress/:orderId/:chargeOrderId" components={HandlingProgress}/>
    <Route path="addAddress" components={AddAddress}/>
    <Route path="addressEdit/:addressId" components={AddressEdit}/>
    <Route path="addressList" components={AddressList}/>
    <Route path="orderList(/:type)" components={OrderList}/>
    <Route path="orderDetails/:orderId/:chargeOrderId" components={OrderDetails}/>
    <Route path="passInformation(/:type)" components={PassInformation}/>
    <Route path="agreement/:type" components={Agreement}/> 

    <Route path="checkExpress" components={CheckExpress}/> 
    <Route path="checkProgress" components={CheckProgress}/> 

    {/*<Route path="路由地址" getComponents={(nextState, cb) => {  agreement  
        require.ensure([], (require) => {
          cb(null, require('./组件路径/按需加载demo').default)
        }, 'chunkName')
      }} />*/}
    <Route path="*" component={NotFoundPage}/>
  </Route>
);